<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<h1>登录</h1>
		<p>用户名 : <input type="text" id="username"></p>
		<p>密&nbsp;&nbsp;&nbsp;码 : <input type="text" id="password"></p>
		<p><button id="btn">登录</button></p>

		<script type="text/javascript">
			document.querySelector("#btn").onclick = function() {
					//获取数据
					let username_value = document.querySelector('#username').value
					let password_value = document.querySelector('#password').value
					//测试数据
					 console.log(username_value,password_value);
					let xhr = new XMLHttpRequest();
					xhr.open("GET", "js_GETproject.php?username="+username_value+"&password="+password_value);
					//发送请求
					xhr.send()
					xhr.onreadystatechange = function() {
						if( xhr.readyState === 4){
						                  // console.log(xhr.responseText);
						                  if( xhr.responseText === "登录成功"){
						                        alert("恭喜登录成功");
						                  }else{
						                        alert("抱歉，请重新登录!");
						                  }
						            }
						      }
						}
		</script>
	</body>
</html>
